﻿/****************************************************************
*   作者：Morain
*   创建时间：2018/2/26 16:19:58
*   描述说明：
*****************************************************************/
using Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace Hotfix
{
  [MessageHandler(AppType.Gate)]
  public class TestHandler : AMHandler<C2G_Login, G2C_Login>
  {
    protected async override void Run(Session session, C2G_Login message, Action<G2C_Login> reply)
    {
      G2C_Login response = new G2C_Login();
      try
      {
        StartConfig gateConfig = Game.Scene.GetComponent<StartConfigComponent>().LocationConfig;
        InnerConfig innerConfig = gateConfig.GetComponent<InnerConfig>();
        Session location = Game.Scene.GetComponent<NetInnerComponent>().Get(innerConfig.IPEndPoint);
        G2L_Ping g2L_Ping = new G2L_Ping();
        L2G_Ping l2G_Ping = (L2G_Ping)await location.Call(g2L_Ping);

        response.Message = "登录成功！";
        reply(response);
      }
      catch (Exception e)
      {
        ReplyError(response, e, reply);
      }
    }
  }

  [MessageHandler(AppType.Location)]
  public class L2G_PingHandler : AMHandler<G2L_Ping, L2G_Ping>
  {
    protected override void Run(Session session, G2L_Ping message, Action<L2G_Ping> reply)
    {
      L2G_Ping response = new L2G_Ping();
      Log.Info("......");
      reply(response);
    }
  }
}
